package com.jt.blog.scheduler;

import com.jt.blog.service.SetingService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author : 戴瑞
 * @Description : 定时备份数据库
 * @create : 2018-03-24 11:08
 **/

@Component
@Lazy(false)
public class BackupDatabaseScheduler {

    private Logger log = LoggerFactory.getLogger(BackupDatabaseScheduler.class);

    @Autowired
    private SetingService setingService;


    /**
     * 每天00:00:01  执行定时任务
     *  10 * * * * ?
     *  0 1 0 * * ?
     */
    @Scheduled(cron = "0 1 0 * * ?")
    public void executeBackup(){
        log.info("定时任务: {} 启动","备份数据库文件" );
        setingService.executeBackup();
    }
}
